//    Copyright (C) Kherty.  All rights reserved.
using System;
using System.Windows.Data;
using OpenLS.Chart.UI.Internals;

namespace OpenLS.Chart.UI
{
    class PositionConverter: IValueConverter
    {
        #region IValueConverter Members

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (targetType == typeof(ScatterPanelPosition))
                return ToScatterPanelPosition((DataLabelPosition) value);
            throw new NotSupportedException();
        }

        private static ScatterPanelPosition ToScatterPanelPosition(DataLabelPosition position)
        {
            switch (position)
            {
                    case DataLabelPosition.Bottom:
                    return ScatterPanelPosition.Bottom;
                    case DataLabelPosition.Center:
                    return ScatterPanelPosition.Center;
                    case DataLabelPosition.Left:
                    return ScatterPanelPosition.Left;
                    case DataLabelPosition.Right:
                    return ScatterPanelPosition.Right;
                    case DataLabelPosition.Top:
                    return ScatterPanelPosition.Top;
                    case DataLabelPosition.BestFit:
                    case DataLabelPosition.InsideBase:
                    case DataLabelPosition.InsideEnd:
                    case DataLabelPosition.OutsideEnd:
                    return ScatterPanelPosition.Right;
                default:
                    throw new NotSupportedException(position.ToString());
            }
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotSupportedException();
        }

        #endregion
    }
}
